package com.wwmz.mebatis.v1.config;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by wumz on 2020/10/14 15:18
 */
public class MyMapperProxy implements InvocationHandler {

    private MySqlSession sqlSession;

    MyMapperProxy(MySqlSession sqlSession){
        this.sqlSession = sqlSession;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        String mapperInterface = method.getDeclaringClass().getName();
        String methodName = method.getName();
        String statementId = mapperInterface + "." + methodName;
        return sqlSession.seletOne(statementId, args[0]);
    }
}
